fn main() {
    //控制流

    //if else
    let x = 1;
    if x == 1{
        println!("x = 1");
    }else {
        println!("x != 1");
    }

    //let中使用 if else
    //if else 分支里结尾不要加分号
    //每个分支里的类型要相同
    let condition = true;
    let y = if condition{
        1
    }else {
        2
    };
    println!("y = {}",y);

    //循环 loop
    let mut  counter = 0;
    loop{
        println!("counter = {}",counter);
        if counter == 4{
            break;
        }
        //counter++ 不行
        counter += 1;
    }

    //let中使用loop
    let total = loop{
        counter += 1;
        if counter == 10{
            break counter;
        }
    };
    println!("total = {}",total);

    //while
    let mut i = 0;
    while i != 10{
        i += 1;
    }
    println!("i = {}",i);

    //for
    let arr:[u32;5] = [1,2,3,4,5];
    for el in arr.iter() {
        println!("el = {}",el);
    }

    println!("Hello, world!");
}
